<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { $DrugDetail } from '@/api/drug'
import { useRoute } from 'vue-router'
const route = useRoute()

const drugDetail = ref({})

onMounted(() => {
    // 获取药品列表
    $DrugDetail({
        id: route.query.id
    }).then((res) => {
        drugDetail.value = res.data
    })
})

</script>

<template>
    <div class="drug-introduce">
        <img class="drug-img" src="@/images/drug/drug-introduce-bg.jpg" alt="">
        <nav-content navData="&nbsp;&nbsp;>&nbsp;&nbsp;药品管理&nbsp;&nbsp;>&nbsp;&nbsp;药品介绍"></nav-content>
        <div class="drug-details">
            <div class="drug-details-top">
                <div class="drug-details-top-img">
                    <img :src="drugDetail.url" alt="">
                </div>
                <div class="drug-details-top-information">
                    <div class="drug-details-top-name">通用名称：{{ drugDetail.name }}</div>
                    <div class="drug-details-top-company">生产公司：{{ drugDetail.company }}</div>
                    <div class="drug-details-top-function">功能主治：{{ drugDetail.function }}</div>
                </div>
            </div>
            <div class="drug-box">
                <div class="drug-describe">
                    <div class="drug-theme">主要成分</div>
                    <div class="drug-text">本品活性成份：{{ drugDetail.components }}</div>
                </div>
                <div class="drug-describe">
                    <div class="drug-theme">功能主治</div>
                    <div class="drug-text">{{ drugDetail.function }}</div>
                </div>
                <div class="drug-describe">
                    <div class="drug-theme">用法用量</div>
                    <div class="drug-text">{{ drugDetail.usageDosage }}</div>
                </div>
                <div class="drug-describe">
                    <div class="drug-theme">注意事项</div>
                    <div class="drug-text">{{ drugDetail.precautions }}</div>
                </div>
                <div class="drug-describe">
                    <div class="drug-theme">不良反应</div>
                    <div class="drug-text">{{ drugDetail.adverse }}
                    </div>
                </div>
            </div>

        </div>
    </div>
</template>

<style scoped lang="scss">
.drug-introduce {

    .drug-img {
        display: flex;
        width: 100vw;
        height: 50vh;
    }

    .drug-details {
        display: flex;
        flex-direction: column;
        width: 67vw;
        margin: 0 auto;

        .drug-details-top {
            display: flex;
            width: 67vw;
            height: 30vh;
            background: url("@/images/drug/introduce.png") no-repeat;
            background-size: 100% 100%;
            padding: 8vh 3.5vw;
            margin-bottom: 6vh;

            .drug-details-top-img {
                flex: 1;
                display: flex;
                align-items: center;

                img {
                    width: 8vw;
                    height: 8vw;
                }
            }

            .drug-details-top-information {
                flex: 4;
                display: flex;
                flex-direction: column;
                justify-content: space-around;
                color: #fff;
                font-size: 1vw;
            }
        }

        .drug-box {
            background-color: #f5f5f5;
            padding: 4vh 2vw;

            .drug-describe {
                display: flex;
                flex-direction: column;
                margin-bottom: 5vh;

                .drug-theme {
                    display: flex;
                    line-height: 2.5vh;
                    padding-left: 1.2vw;
                    font-size: 1.2vw;
                    font-weight: 800;
                    border-left: 0.3vw solid #45c998;
                }

                .drug-text {
                    font-size: 1vw;
                    line-height: 2em;
                    margin-top: 2vh;
                    padding: 0 1.5vw;
                }
            }
        }

    }
}
</style>